Skip to content

Backport WebSocket maxPayloadSize fixes to v6.x#5428

Merged
mcollina merged 1 commit into
v6.xfrom
backport-a027a4a0-v6.x
Jun 15, 2026
Merged

Backport WebSocket maxPayloadSize fixes to v6.x#5428
mcollina merged 1 commit into
v6.xfrom
backport-a027a4a0-v6.x

Conversation

@mcollina

Copy link
Copy Markdown
Member

Summary

  • backport WebSocket maxPayloadSize fragment enforcement from a027a4a04c6c055877d1abaf5f60ee4917e7e01f to v6.x
  • add webSocket.maxFragments support and tests for regular, compressed, and empty fragments
  • adapt the backport to v6 WebSocket internals and keep WebSocketStream changes out because v6 does not include that API

Tests

  • npx borp -p "test/websocket/fragments.js"
  • npx borp -p "test/websocket/permessage-deflate-limit.js"
  • npx standard lib/dispatcher/dispatcher-base.js lib/web/websocket/receiver.js lib/web/websocket/websocket.js test/websocket/fragments.js test/websocket/permessage-deflate-limit.js
  • npm run test:typescript
  • npm run test:websocket

* feat: add configurable maxPayloadSize for WebSocket (#4955)

(cherry picked from commit bd91f86)
Signed-off-by: Matteo Collina <hello@matteocollina.com>

* test: fix flaky permessage-deflate limit timeout (#5229)

(cherry picked from commit 9d82667)
Signed-off-by: Matteo Collina <hello@matteocollina.com>

* fix(websocket): enforce max payload size across fragments

Account for previously received fragment bytes when checking WebSocket payload size limits, so fragmented messages cannot exceed maxPayloadSize by splitting the payload across frames.

Add coverage for cumulative fragmented payload size enforcement.

Co-authored-by: Matthew Aitken <maitken033380023@gmail.com>
(cherry picked from commit b4c287b)
Signed-off-by: Matteo Collina <hello@matteocollina.com>

* websocket: handle empty fragments and stream limits

Treat zero-byte frames as real fragments so fragmented messages can start
with an empty frame and empty continuations still count toward
maxFragments.

Pass dispatcher WebSocket limits through to WebSocketStream's parser, add
regression coverage for WebSocket and WebSocketStream fragment limits, make
the fragment close tests wait for both endpoints, and fix the Client docs
typo for maxFragments.

Co-authored-by: Ulises Gascon <ulisesgascongonzalez@gmail.com>
(cherry picked from commit c5ed787)
Signed-off-by: Matteo Collina <hello@matteocollina.com>

---------

Signed-off-by: Matteo Collina <hello@matteocollina.com>
Co-authored-by: Matthew Aitken <maitken033380023@gmail.com>
Co-authored-by: Luigi Pinca <luigipinca@gmail.com>
Co-authored-by: Ulises Gascon <ulisesgascongonzalez@gmail.com>
@mcollina mcollina merged commit b7f252e into v6.x Jun 15, 2026
52 of 55 checks passed
@mcollina mcollina deleted the backport-a027a4a0-v6.x branch June 15, 2026 13:01
@github-actions github-actions Bot mentioned this pull request Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant